//
//  HomeViewController.swift
//  TestDemo
//
//  Created by 赵洋 on 2017/6/1.
//  Copyright © 2017年 赵洋. All rights reserved.
//

import UIKit
//import AVFoundation
//import MBProgressHUD
class HomeViewController: UIViewController  {
    
    @IBOutlet weak var scanButton: UIButton!
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        scanButton.imageEdgeInsets = UIEdgeInsetsMake(0, 50, 0, 0)
        scanButton.titleEdgeInsets = UIEdgeInsetsMake(scanButton.imageView!.height+100, 0, 0, 0)
        
        guard  let userinfo = UserDefaults.standard.object(forKey: "userinfo") as? [String:String]  else {
            performSegue(withIdentifier: "Home2Login", sender: nil)
            
            return
        }

        User.shareInstance.name = userinfo["username"]
        User.shareInstance.password = userinfo["password"]
    }
   
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    // MARK: - IBAction
    @IBAction func logout() {
        UserDefaults.standard.removeObject(forKey: "userinfo")
        performSegue(withIdentifier: "Home2Login", sender: nil)
    }
    
    @IBAction func scanButtonClicked(_ sender: UIButton) {
        //let borrow = sender.tag ==
       let scanVC = ScanViewController()
        navigationController?.pushViewController(scanVC, animated: true)
    }
    
   
}
